build:
	g++ ./skiplist.cpp -g -o skiplist

profile:
	# module use /opt/modulefiles
	# module load perf
	# perf --version
	perf record -e '{cycles,instructions,cpu-clock,ll_cache_miss,ll_cache,l2d_cache,l2d_cache_refill,mem_access,memory_error,branch-load-misses,branch-loads,dTLB-load-misses,dTLB-loads}:S' -C 4 -g -F 999 -o ./perf.data taskset -c 4 ./skiplist

parse:
	perf script > perf.script
	perf report > perf.report
	perf report --call-graph=none > perf.no_call.report

compare_random:
	g++ ./skiplist_random.cpp -g -o skiplist_random
	g++ ./skiplist_timer.cpp -g -o skiplist_timer
	for i in {1..5}; do ./skiplist_random >> ./data/skiplist_random.log; done
	for i in {1..5}; do ./skiplist_timer >> ./data/skiplist_timer.log; done

cmp_random_profile:
	perf record -e '{cycles,instructions,cpu-clock,ll_cache_miss,ll_cache,l2d_cache,l2d_cache_refill,mem_access,memory_error,branch-load-misses,branch-loads,dTLB-load-misses,dTLB-loads}:S' -C 4 -g -F 999 -o ./data/random.data taskset -c 4 ./skiplist_random >> ./data/skiplist_random_profile.log
	perf record -e '{cycles,instructions,cpu-clock,ll_cache_miss,ll_cache,l2d_cache,l2d_cache_refill,mem_access,memory_error,branch-load-misses,branch-loads,dTLB-load-misses,dTLB-loads}:S' -C 4 -g -F 999 -o ./data/timer.data taskset -c 4 ./skiplist_timer >> ./data/skiplist_timer_profile.log
	perf script -i ./data/random.data > ./data/random.script
	perf script -i ./data/timer.data  > ./data/timer.script
	perf report -i ./data/random.data > ./data/random.report
	perf report -i ./data/timer.data  > ./data/timer.report


cmp_mempool:
	g++ ./skiplist_mempool_baseline.cpp -g -o skiplist_mempool_baseline
	g++ ./skiplist_mempool.cpp -g -o skiplist_mempool
	for i in {1..5}; do ./skiplist_mempool_baseline >> ./data/skiplist_mempool_baseline.log; done
	for i in {1..5}; do ./skiplist_mempool >> ./data/skiplist_mempool.log; done
